package util;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

public class ClienteHelper {
	
	public static String dateToStringView(Date data){
		
		SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
		
		return sdf.format(data);
	}
	
	public static String dateToStringDB(Date data){
		
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
		
		return sdf.format(data);
	}
	
	public static Date stringToDate(String data){
		String [] aux = data.split("/");
		int dia = Integer.parseInt(aux[0]);
		int mes = Integer.parseInt(aux[1]);
		int ano = Integer.parseInt(aux[2]);
		
		Calendar cal = Calendar.getInstance();
		cal.set(Calendar.DAY_OF_MONTH, dia);
		cal.set(Calendar.MONTH, (mes-1));
		cal.set(Calendar.YEAR, ano);
		
		return cal.getTime();
		
	}
}
